<?php

/**
 * Ares api definition configure file 
 *
 * @author xingkun
 * @date 2014/11/07
 */
class ApiDefinition {

    const PARAM_TYPE_INT = 'int';
    const PARAM_TYPE_STR = 'str';
    const PARAM_TYPE_BOOL = 'bool';
    const PARAM_TYPE_ENUM = 'enum';
    const PARAM_TYPE_JSON = 'json';
    const PARAM_TYPE_NUM = 'num';

    // 'xx'=>array('required'=>true, 'type'=>'int', 'minLength'=>5, 'maxLength'=>5, 'min'=>2, 'max'=>5, 'default'=>1),
    // 'xx'=>array('required'=>true, 'type'=>'str', 'minLength'=>5, 'maxLength'=>5, 'default'=>1),
    // 'xx'=>array('required'=>true, 'type'=>'bool', 'enum'=>array(1,2,3) 'default'=>1),
    // 'xx'=>array('required'=>true, 'type'=>'enum', 'enum'=>array(1,2,3) 'default'=>1),
    // App客户端配置
    static $cfgAllowedAppKeys = array('iphone' => 'xxxxxx', 'android' => 'xxxxxx');
    static $cfgAllowedAppSecrects = array('iphone' => 'xxxxxx', 'android' => 'xxxxxx');
    static $cfgAllowedApiVersions = array('1.0', '1.1');
    // System Parameters
    static $sysParams = array(
        'accessToken' => '',
        'client' => null,
        'app_key' => null,
        'v' => null,
        'sign' => null,
        'secret_verify' => null,
    );
    // API interface definition
    static $apiMapping = array(
        /*         * ***    system    *** */
        'api/getaccesstoken' => array(
            'route' => 'api/getAccessToken',
            'verb' => 'GET',
        ),
        
        /*         * **** user center ***** */
        //登录
        'api/login' => array(
            'route' => 'api/login',
            'verb' => 'GET',
            'parameters' => array(
                'mobileNo' => null,
                'pwd' => null,
                'mode' => null,
            ),
        ),
        //退出
        'api/logout' => array(
            'route' => 'api/logout',
            'verb' => 'POST',
            'parameters' => array(
                'token' => null,
            ),
        ),
        //检查邮箱是否已注册
        'api/checkemail' => array(
            'route' => 'api/checkEmail',
            'verb' => 'GET',
            'parameters' => array(
                'email' => null,
            ),
        ),
        //检查手机是否已注册
        'api/checkmobile' => array(
            'route' => 'api/checkMobile',
            'verb' => 'GET',
            'parameters' => array(
                'mobile' => null,
            ),
        ),
        //验证邮箱是否为真实邮箱
        'api/verifyemail' => array(
            'route' => 'api/verifyEmail',
            'verb' => 'GET',
            'parameters' => array(
                'email' => null,
            ),
        ),
        //检查手机是否为真实手机
        'api/verifymobile' => array(
            'route' => 'api/verifyMobile',
            'verb' => 'GET',
            'parameters' => array(
                'mobile' => null,
            ),
        ),
        //个人信息
        'api/getcustomer' => array(
            'route' => 'api/getCustomer',
            'verb' => 'GET',
            'parameters' => array(
                'token' => null,
            ),
        ),
        //修改邮箱
        'api/changeemail' => array(
            'route' => 'api/changeEmail',
            'verb' => 'POST',
            'parameters' => array(
                'token' => null,
                'new_email' => null,
            ),
        ),
        //修改手机
        'api/changemobile' => array(
            'route' => 'api/changeMobile',
            'verb' => 'POST',
            'parameters' => array(
                'token' => null,
                'new_mobile' => null,
            ),
        ),
        //修改姓名或昵称
        'api/changeprofile' => array(
            'route' => 'api/changeProfile',
            'verb' => 'POST',
            'parameters' => array(
                'token' => null,
                'new_name' => null,
                'mode' => null, // 1 姓名  2 昵称
            ),
        ),
        //注册
        'api/register' => array(
            'route' => 'api/register',
            'verb' => 'POST',
            'parameters' => array(
                'mobileNo' => null,
                'pwd' => null,
                'nickName' => null,
                'mode' => null, // 1. email 2. phone 3. nickname
            ),
        ),
        //修改密码
        'api/changepwd' => array(
            'route' => 'api/changePwd',
            'verb' => 'POST',
            'parameters' => array(
                'token' => null,
                'old_password' => null,
                'new_password' => null,
                'confirm_password' => null,
            ),
        ),
        //忘记密码
        'api/forgetpwd' => array(
            'route' => 'api/forgetPwd',
            'verb' => 'GET',
            'parameters' => array(
                'username' => null,
                'mode' => null,
                'new_password' => '',
            ),
        ),
        //上传头像
        'api/uploadphoto' => array(
            'route' => 'api/uploadPhoto',
            'verb' => 'POST',
            'parameters' => array(
                'token' => null,
            ),
        ),
        // test
        'api/test' => array(
            'route' => 'api/test',
            'verb' => 'GET',
        ),
        'api/getappinfo' => array(
            'route' => 'api/getAppInfo',
            'verb' => 'GET',
        ),
    ); //end $definition
}
